#!/usr/bin/python
import pygame
import player
import ball
import draw
import auxs
import level
import game
import menu
#~ import menu
from defs import *

# Initialization
# Music (pre init)
freq = 44100   
pygame.mixer.pre_init(freq)

# Game engine
pygame.init()

# Screen
screen 	= pygame.display.set_mode(screen_size)
pygame.display.set_caption("Pong")

# Font
pygame.font.init()
font = pygame.font.Font(None, 36)
timer_font = pygame.font.Font(None, 27)
pause_font = pygame.font.Font(None, 150)

# Background
background_image = pygame.image.load("sprites/back4.png").convert()

# Paddles
#~ paddle_image = pygame.image.load ("sprites/paleta1.png").convert()
#~ paddle_image = pygame.transform.scale(pygame.image.load \
        #~ ("sprites/paleta1.png").convert(), (paddle_width, paddle_height))
#~ paddle_width  = paddle_image.get_width()
#~ paddle_height = paddle_image.get_width()
    
player1 = player.Player(paddle_1_x, paddle_1_y, paddle_speed_rate, paddle_width, paddle_height)
player2 = player.Player(paddle_2_x, paddle_2_y, paddle_speed_rate, paddle_width, paddle_height)

# Ball
ball_image = pygame.transform.scale(pygame.image.load \
    ("sprites/ball6.png").convert(), (ball_width, ball_height))
# Make color white transparent when bliting
pygame.Surface.set_colorkey(ball_image, white)
ball = ball.Ball(ball_x, ball_y, 0, 0, ball_width, ball_height)

# Screen limits
ball.setLimits(limit_x, limit_y, limit_width, limit_height)
player1.setLimits(limit_x, limit_y, limit_width, limit_height)
player2.setLimits(limit_x, limit_y, limit_width, limit_height)

# Clock
clock = pygame.time.Clock()

# Drawing object
draw = draw.Draw(screen, background_image)
draw.setColors(black, white)
draw.setNumPosition([pos_score_p1, pos_score_p2])
draw.setTimePosition([pos_timer_lvl, pos_timer_total])
draw.setSprite([[ball_image, [ball_x, ball_y]]])

# Game
pong = game.Game(player1, player2, ball, draw)
pong.setClock(clock)
pong.setNumFont(font)
pong.setTimerFont(timer_font)
pong.setPauseFont(pause_font)


#Menu, un juego aparte, desde aca se llama al pong  y todo lo demas
menu = menu.Menu(pong)
menu.start()
	
pygame.quit()
